import api from '@/api'
import { isCode } from '@/utils'
const initState = () => {
    return {
        changEmailData: {
            isShow: false,
            cardTransition: "",
            title: "Change Email Address",
            desc: "Please enter the new email address you wish to change to and for safety reason type in your Enchi.io account password.",
            btn: "Next",
            email: {
                title: "Email address: ",
                placeholder: "Enter email",
                tip: "This email address is the same as previous one.", //错误提示
                value: "", //输入框的值
                name: "email", //正则名称
            },
            password: {
                title: "Password: ",
                placeholder: "Password",
                tip: "Please enter your password.",
                asyncTip: "Incorrect password.", //动态校验提示
                value: "",
                name: "password",
                type: "password",
            },
        },
    };
};

const state = initState();

const mutations = {
    //打开更改邮箱弹窗
    openChangeEmailPop(state, type) {
        state.changEmailData.cardTransition = type ? type : 'contentEnterBottom';
        state.changEmailData.isShow = true;
    },
    //关闭更改邮箱弹窗
    closeChangeEmailPop(state, type) {
        state.changEmailData.cardTransition = type ? type : 'contentLeaveBottom';
        state.changEmailData.isShow = false;
        setTimeout(() => {
            this.commit('changeEmail/resetState');
        });
    },
    resetState(state) {
        Object.assign(state, initState());
    }
};

const actions = {

};

const getters = {};

export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
};